<template>
  <div id="goods-desc">
    <div class="title">{{ goodsDesc.title }}</div>
    <hr />
    <div class="content" v-html="goodsDesc.content"></div>
  </div>
</template>

<script>
export default {
  // 一、获取id
  props: ["id"],
  data() {
    return {
      goodsDesc: {},
    }
  },
  methods: {
    // 二、根据id获取数据,保存下来然后渲染页面
    async getDesc() {
      const { data } = await this.$http.get(`/api/goods/getdesc/${this.id}`)
      if (data.status === 0) {
        // console.log(data)
        this.goodsDesc = data.message[0]
      }
    },
  },
  created() {
    this.getDesc()
  },
}
</script>

<style lang="scss">
#goods-desc {
  img {
    width: 100%;
  }
  .title {
    font-size: 20px;
  }
}
</style>
